#!/usr/bin/php                                                                                                     
                                                                                                                   
<?PHP                                                                                                                                                                                                                                 
# Ignore interrupt signal                                                                                          
pcntl_signal(SIGHUP, SIG_IGN);                                                                                     
                                                                                                                   
if (count($argv) < 4) {                                                                                            
    print "NOOP Usage: logger.agi <ClientID> <IPAddress> <Phone1> <Phone2> <StartDate> <Duration> <URL>\n";        
    exit(1);                                                                                                       
}                                                                                                                  
                                                                                                                   
# Parse command line arguments                                                                                     
$Extension = $argv[1];                                                                                                                                                                                         
$Phone = $argv[2];                                                                                                                                                                                               
$StartDate = $argv[3];                                                                                             
$Duration = $argv[4];                                                                                                                                                                                                 
                                                                                                                   
# Convert time                                                                                                     
$StartDateConverted = date(DATE_ATOM, strtotime($StartDate));                                                      
                                                                                                                   
# Initialize                                                                                                       
$SOAP = new SoapClient('http://192.168.3.103/PhoneService.asmx?WSDL', array('exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE,) );                                                                    
                                                                                                                   
# Make a request                                                                                                   
var_dump($SOAP->LogCall(array('Extension'=>$Extension, 'Phone'=>$Phone, 'StartDate'=>$StartDateConverted, 'Duration'=>$Duration)));                                          
?>                                                                                                                                             

